<%@ page import="com.baosight.iplat4j.core.web.threadlocal.UserSession" %>
<%@ page import="com.baosight.iplat4j.core.security.user.UserManagerRestImpl" %>
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>

<%@page import="com.baosight.iplat4j.core.FrameworkInfo" %>
<%@ page import="com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext" %>
<%@ page import="com.baosight.iplat4j.core.log.Logger" %>
<%@ page import="com.baosight.iplat4j.core.log.LoggerFactory" %>
<html>
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<title></title>
	<%
		String logoutUrl ="login.jsp";
		try{
			if(null!=Class.forName("com.baosight.eplat.be.aa.client.config.OauthClientConfig")){
				logoutUrl = PlatApplicationContext.getProperty("eplat.security.client.logoutUrl");
            /*sdk1.2.0版本且使用业务交付配置时放开以下注释
            if(!StringUtils.isNotEmpty(logoutUrl)){
                String clientAddrProperty = PlatApplicationContext.getProperty("eplat.security.client.app.url");
                String serverAddrProperty = PlatApplicationContext.getProperty("eplat.security.client.auth.url");
                logoutUrl=serverAddrProperty + "/logout?callback=" + clientAddrProperty + "/logout";
            }*/
				logoutUrl = logoutUrl + "&token=" + session.getAttribute("oauth2_token");
			}
		}catch(ClassNotFoundException ex) {
			final Logger logger = LoggerFactory.getLogger("index");
			logger.info("未对接认证，使用默认登出链接");
		}
		request.setAttribute("logoutUrl",logoutUrl);
		String domain = FrameworkInfo.getProjectAppTopDomain();
		if (domain != null && domain.startsWith(".")) {
			domain = domain.substring(1);
	%>
	<script type="text/javascript">
		try {
			document.domain = '<%= domain %>';
		} catch (ex) {
			alert('domain not valid[<%= domain %>]');
		}
	</script>
	<%
		}
	%>
</head>
<%--<head>--%>
	<%--<meta http-equiv="X-UA-Compatible" content="IE=edge"/>--%>
	<%--<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>--%>
	<%--<title></title>--%>
<%--</head>--%>

<body>
<%
	UserSession.web2Service(request);
	String userName = UserSession.getLoginName();
	String userId = UserSession.getUserId();
	request.setAttribute("userCode",userName);
	request.setAttribute("userId",userId);
%>
<c:set var="userCode" value="<%=userName%>"/>
<c:set var="_userId" value="<%=userId%>"/>
<p class="text-danger">
	success:{"loginName": "${userCode}","id": "${_userId}","token": "${userCode}","avatar": "user-admin.png"}
</p>
<script>
	<%--window.location="${ctx}/index.html"--%>
	window.location.href = '${ctx}/web/PORTALPAGE';
</script>
</body>
</html>
